package lesson09;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class MainPanel extends JPanel implements ActionListener {
    private JButton btn1 = new JButton();
    private Test05 mainFrame;
    public MainPanel(Test05 mainFrame){
        this.mainFrame = mainFrame;
        this.setLayout(null);
        JLabel label1 = new JLabel("主页面");
        label1.setBounds(100,50,200,100);
        btn1.setBounds(10,10,100,20);
        btn1.setText("按钮1");
        btn1.addActionListener(this);
        this.add(label1);
        this.add(btn1);
        this.setOpaque(false);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if(e.getSource() == btn1){
            mainFrame.switchPanel("login");
        }
    }
}
